GtkApplication: remove end session API
authorRyan Lortie <desrt@desrt.ca>
Mon, 20 Feb 2012 20:47:29 +0000 (21:47 +0100)
committerRyan Lortie <desrt@desrt.ca>
Tue, 21 Feb 2012 00:23:01 +0000 (01:23 +0100)
This seems a bit "too powerful" and unlikely to be used by most
applications.  Remove it from now, until someone comes up with a strong
desire for it.

https://bugzilla.gnome.org/show_bug.cgi?id=670485

docs/reference/gtk/gtk3-sections.txt
gtk/gtk.symbols
gtk/gtkapplication.c
gtk/gtkapplication.h
tests/testlogout.c

index 4674beb913dcdaa7a71c33ebf4cf39c2b0f979db..cdcad3f662d1f15baaa254f2bc3158047b45bff1 100644 (file)
@@ -7019,8 +7019,6 @@ GtkApplicationInhibitFlags
 gtk_application_inhibit
 gtk_application_uninhibit
 gtk_application_is_inhibited
-GtkApplicationEndSessionStyle
-gtk_application_end_session
 
 <SUBSECTION>
 gtk_application_get_app_menu
index 9a49a41ec50fffef454dc9e81980599737f81bbf..8742cb9685c5b7b84ad397c7fff0050847b63595 100644 (file)
@@ -227,8 +227,6 @@ gtk_app_chooser_widget_set_show_other
 gtk_app_chooser_widget_set_show_recommended
 gtk_application_add_accelerator
 gtk_application_add_window
-gtk_application_end_session
-gtk_application_end_session_style_get_type
 gtk_application_get_app_menu
 gtk_application_get_menubar
 gtk_application_get_type
index d5bdd730377b66a037624e36125d3103478333d5..241122601d812ddb0087fcb22576c41a31dafd16 100644 (file)
  * An application can be informed when the session is about to end
  * by connecting to the #GtkApplication::quit signal.
  *
- * An application can request the session to be ended by calling
- * gtk_application_end_session().
- *
  * An application can block various ways to end the session with
  * the gtk_application_inhibit() function. Typical use cases for
  * this kind of inhibiting are long-running, uninterruptible operations,
@@ -1499,67 +1496,6 @@ gtk_application_is_inhibited (GtkApplication             *application,
   return inhibited;
 }
 
-/**
- * GtkApplicationEndSessionStyle:
- * @GTK_APPLICATION_LOGOUT: End the session by logging out
- * @GTK_APPLICATION_REBOOT: Restart the computer
- * @GTK_APPLICATION_SHUTDOWN: Shut the computer down
- *
- * Different ways to end a user session, for use with
- * gtk_application_end_session().
- */
-
-/**
- * gtk_application_end_session:
- * @application: the #GtkApplication
- * @style: the desired kind of session end
- * @request_confirmation: whether or not the user should get a chance
- *     to confirm the action
- *
- * Requests that the session manager end the current session.
- * @style indicates how the session should be ended, and
- * @request_confirmation indicates whether or not the user should be
- * given a chance to confirm the action. Both of these parameters are
- * merely hints though; the session manager may choose to ignore them.
- *
- * Return value: %TRUE if the request was sent; %FALSE if it could not
- *     be sent (eg, because it could not connect to the session manager)
- *
- * Since: 3.4
- */
-gboolean
-gtk_application_end_session (GtkApplication                *application,
-                             GtkApplicationEndSessionStyle  style,
-                             gboolean                       request_confirmation)
-{
-  g_return_val_if_fail (GTK_IS_APPLICATION (application), FALSE);
-  g_return_val_if_fail (!g_application_get_is_remote (G_APPLICATION (application)), FALSE);
-  g_return_val_if_fail (application->priv->sm_proxy != NULL, FALSE);
-
-  switch (style)
-    {
-    case GTK_APPLICATION_LOGOUT:
-      g_dbus_proxy_call (application->priv->sm_proxy,
-                         "Logout",
-                         g_variant_new ("(u)", request_confirmation ? 0 : 1),
-                         G_DBUS_CALL_FLAGS_NONE,
-                         G_MAXINT,
-                         NULL, NULL, NULL);
-      break;
-    case GTK_APPLICATION_REBOOT:
-    case GTK_APPLICATION_SHUTDOWN:
-      g_dbus_proxy_call (application->priv->sm_proxy,
-                         "Shutdown",
-                         NULL,
-                         G_DBUS_CALL_FLAGS_NONE,
-                         G_MAXINT,
-                         NULL, NULL, NULL);
-      break;
-    }
-
-  return TRUE;
-}
-
 #elif defined(GDK_WINDOWING_QUARTZ)
 
 /* OS X implementation copied from EggSMClient, but simplified since
@@ -1683,58 +1619,6 @@ gtk_application_is_inhibited (GtkApplication             *application,
   return FALSE;
 }
 
-gboolean
-gtk_application_end_session (GtkApplication                *application,
-                             GtkApplicationEndSessionStyle  style,
-                             gboolean                       request_confirmation)
-{
-  static const ProcessSerialNumber loginwindow_psn = { 0, kSystemProcess };
-  AppleEvent event = { typeNull, NULL };
-  AppleEvent reply = { typeNull, NULL };
-  AEAddressDesc target;
-  AEEventID id;
-  OSErr err;
-
-  switch (style)
-    {
-    case GTK_APPLICATION_LOGOUT:
-      id = request_confirmation ? kAELogOut : kAEReallyLogOut;
-      break;
-    case GTK_APPLICATION_REBOOT:
-      id = request_confirmation ? kAEShowRestartDialog : kAERestart;
-      break;
-    case GTK_APPLICATION_SHUTDOWN:
-      id = request_confirmation ? kAEShowShutdownDialog : kAEShutDown;
-      break;
-    }
-
-  err = AECreateDesc (typeProcessSerialNumber, &loginwindow_psn,
-                      sizeof (loginwindow_psn), &target);
-  if (err != noErr)
-    {
-      g_warning ("Could not create descriptor for loginwindow: %d", err);
-      return FALSE;
-    }
-
-  err = AECreateAppleEvent (kCoreEventClass, id, &target,
-                            kAutoGenerateReturnID, kAnyTransactionID,
-                            &event);
-  AEDisposeDesc (&target);
-  if (err != noErr)
-    {
-      g_warning ("Could not create logout AppleEvent: %d", err);
-      return FALSE;
-    }
-
-  err = AESend (&event, &reply, kAENoReply, kAENormalPriority,
-                kAEDefaultTimeout, NULL, NULL);
-  AEDisposeDesc (&event);
- if (err == noErr)
-    AEDisposeDesc (&reply);
-
-  return err == noErr;
-}
-
 #else
 
 /* Trivial implementation.
@@ -1765,12 +1649,4 @@ gtk_application_is_inhibited (GtkApplication             *application,
   return FALSE;
 }
 
-gboolean
-gtk_application_end_session (GtkApplication                *application,
-                             GtkApplicationEndSessionStyle  style,
-                             gboolean                       request_confirmation)
-{
-  return FALSE;
-}
-
 #endif
index b9a9ad789868fe52e3f16771dc104d5e0c1a577f..092d90c130a96660f7c521cc283e967cebb8dbfe 100644 (file)
@@ -110,16 +110,6 @@ void             gtk_application_uninhibit          (GtkApplication
 gboolean         gtk_application_is_inhibited       (GtkApplication             *application,
                                                      GtkApplicationInhibitFlags  flags);
 
-typedef enum {
-  GTK_APPLICATION_LOGOUT,
-  GTK_APPLICATION_REBOOT,
-  GTK_APPLICATION_SHUTDOWN
-} GtkApplicationEndSessionStyle;
-
-gboolean         gtk_application_end_session        (GtkApplication                *application,
-                                                     GtkApplicationEndSessionStyle  style,
-                                                     gboolean                       request_confirmation);
-
 G_END_DECLS
 
 #endif /* __GTK_APPLICATION_H__ */
index 6c17f1a9361b26934a0a3c6c6cde70ac20deedb7..8fda9e7f0cc087457df48ab8a9a431b5d8055ef3 100644 (file)
@@ -7,32 +7,6 @@ static GtkWidget *inhibit_switch;
 static GtkWidget *inhibit_suspend;
 static GtkWidget *inhibit_idle;
 static GtkWidget *inhibit_label;
-static GtkWidget *end_combo;
-static GtkWidget *end_confirm;
-
-static void
-end_session (GtkButton *button, GtkApplication *app)
-{
-  const gchar *id;
-  GtkApplicationEndSessionStyle style;
-  gboolean confirm;
-
-  id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (end_combo));
-  if (g_strcmp0 (id, "logout") == 0)
-    style = GTK_APPLICATION_LOGOUT;
-  else if (g_strcmp0 (id, "reboot") == 0)
-    style = GTK_APPLICATION_REBOOT;
-  else if (g_strcmp0 (id, "shutdown") == 0)
-    style = GTK_APPLICATION_SHUTDOWN;
-  else
-    style = GTK_APPLICATION_LOGOUT;
-
-  confirm = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (end_confirm));
-
-  g_print ("Calling gtk_application_end_session: %d, %d\n", style, confirm);
-
-  gtk_application_end_session (app, style, confirm);
-}
 
 static void
 inhibitor_toggled (GtkToggleButton *button, GtkApplication *app)
@@ -150,25 +124,6 @@ activate (GtkApplication *app,
   gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
   gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
 
-  gtk_container_add (GTK_CONTAINER (box), grid);
-
-  end_combo = gtk_combo_box_text_new ();
-  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (end_combo), "logout", "Logout");
-  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (end_combo), "reboot", "Reboot");
-  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (end_combo), "shutdown", "Shutdown");
-  gtk_combo_box_set_active_id (GTK_COMBO_BOX (end_combo), "logout");
-  gtk_grid_attach (GTK_GRID (grid), end_combo, 0, 0, 1, 1);
-
-  end_confirm = gtk_check_button_new_with_label ("Confirm");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (end_confirm), TRUE);
-  gtk_grid_attach (GTK_GRID (grid), end_confirm, 1, 0, 1, 1);
-
-  button = gtk_button_new_with_label ("Go");
-  g_signal_connect (button, "clicked",
-                    G_CALLBACK (end_session), app);
-
-  gtk_grid_attach (GTK_GRID (grid), button, 2, 0, 1, 1);
-
   gtk_widget_show_all (win);
 
   gtk_application_add_window (app, GTK_WINDOW (win));